package com.xoms.pad.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import com.xoms.pad.controller.res.ListResult;
import com.xoms.pad.controller.res.bean.RDimensionBean;
import com.xoms.pad.controller.springmvc.req.GetDimDetailParam;
import com.xoms.pad.model.AccountBean;
import com.xoms.pad.service.DimensionService;
import com.xoms.pad.service.exception.ServiceException;

/**
 * 维度明细
 * 
 * @author kang
 *
 */
@Component
public class DimDetailController {
	
	@Autowired
	DimensionService dimensionServiceImpl;
	
	/**
	 * 获取维度
	 * 
	 * @param param
	 * @param request
	 * @param response
	 * @return
	 */
	public ListResult<RDimensionBean> getDimension(@Validated GetDimDetailParam param, HttpServletRequest request, HttpServletResponse response) {
		ListResult<RDimensionBean> result = new ListResult<>();
		
		try {
			AccountBean account = (AccountBean) request.getAttribute("account");
			
//			int page = NumUtil.toInt(param.getPage(), 0);
//			int PageSize = NumUtil.toInt(param.getPageSize(), 20);
			
			String did = param.getDid();
			
			
			List<RDimensionBean> resData = dimensionServiceImpl.getDimension(did);
			
			
			if (resData != null) {
				result.setData(resData);
				result.setTotalSize(resData.size());
			}
			
		} catch (ServiceException e) {
			result.setServiceException(e);
		}
		return result;
	}
	
}
